﻿using System.Collections.Generic;
using System.Data.OleDb;

namespace AEM.Data.DAL
{
    public static class FaultLog
    {
        public static bool Add(Model.FaultLog model)
        {
            string condition = @"INSERT INTO [FaultLog] ([LiftNum], [FaultType], [JoinDate]) VALUES (@LiftNum, @FaultType, @JoinDate)";

            int ret = AccessHelper.ExecuteNonQuery(condition, Param(model));
            if (ret > 0) return true;
            return false;
        }

        private static OleDbParameter[] Param(Model.FaultLog model)
        {
            List<OleDbParameter> param = new List<OleDbParameter>();
            param.Add(new OleDbParameter("@LiftNum", model.LiftNum));
            param.Add(new OleDbParameter("@FaultType", (int)model.FaultType));
            param.Add(new OleDbParameter("@JoinDate", model.JoinDate));
            param.Add(new OleDbParameter("@ID", model.ID));
            return param.ToArray();
        }
    }
}
